package com.example.linktop.sqlitedemo;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by linktoplinktop on 2017/5/23.
 */
public class MyOpenHelper  extends SQLiteOpenHelper {


    /**
     * 构造方法
     * @param context 上下文
     */
    public MyOpenHelper(Context context) {

        super(context,  "jiba.db",  null, 2);

    }

    /**
     *
     * @param sqLiteDatabase
     */
    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        //表结构初始化
        sqLiteDatabase.execSQL("create table info(_id integer primary key autoincrement, name varchar(20), phone varchar(20))");

    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
    //版本升级回调
        if (i1 == 2) {

            sqLiteDatabase.execSQL("alter table info add phone varchar(20)");
        }



    }
}


